<template>
	<view class="content page" id="pay_scs" :style="{'--color': color}">
		<status-bar title='支付完成' delta='2'></status-bar>
		<view class="pay_scs_info">
			<text class="icon-success iconfont"></text>
			<view class="pay_scs_text">订单支付完成</view>
			<view class="c_999999">支付完成，请确定订单无误后再确认收货哦！</view>
		</view>
		<view><view class="mb_03 btn7 thmeBg"  @click="toPage(1)" >查看订单</view></view>
		<view><view @click="toPage(2)" class="btn8 thmeBorder thmeColor">返回首页</view></view>
		<dCoupon v-if="isCoupons" :couponArry="getcouponsArry" @closeFunc="isCoupons = false"></dCoupon>
	</view>
</template>

<script>
	import {mapState} from 'vuex';
	import dCoupon from "../../components/Coupons.vue"
	var that;
	export default {
		components: {
			dCoupon
		},
		data() {
			return {
			    timer1:null, 
				isCoupons: false,
				getcouponsArry: '',
				warehouse_mode:0,// 0 我的订单 1 我的仓库
				
			}
		},
		onShow() {
			if (uni.getStorageSync('path') == '11'){ // 订单页返回
			   let homePage = getApp().globalData.homePage;
			   if (homePage.indexOf('home') > -1) {
					uni.reLaunch({
						url: '/pages/user/user'
					})
			   } else {
					uni.reLaunch({
						url: homePage
					})
					uni.setStorageSync('path','-1')
			   }
			}		
			
		},
		onLoad(e) {
			that = this;
			if(e.playid){
				that.getCoupon(e.playid)
			}
		},
		
		onBackPress(){
			uni.setrStorageSync('path',12)
		},
		methods: {
			toPage(i){
			  clearInterval(that.timer1);
			  if(i == 1 && that.warehouse_mode == 1) return that.$rectTo(`/warehouse/house`);
			  if(i == 1 && that.warehouse_mode == 0) return that.$rectTo(`orderList?path=1`);
			  if(i == 2) return that.backHome()	
			},
			
			getCoupon(id) {
				that.timer1 = setInterval(function() {
					that.$http.post({
						url: '/SRA_simMallApi/getNewCouponsLog',
						data: {
							vId: that.vid,
							orderAesStr: id,
							
						}
					}).then(res => {
						if(res.code != 100) return clearInterval(that.timer1);
						if(res.warehouse_mode) that.warehouse_mode = res.warehouse_mode;
						if (res.data && res.data.length > 0) {
							that.getcouponsArry = res.data
							that.isCoupons = true;
							clearInterval(that.timer1);
						}
					})
				}, 1000)
			}
		},
		onUnload() {
			clearInterval(this.timer1);
		},
		computed:{
			...mapState(['color','vid','bid']),
		}
	}
</script>

<style scoped lang="scss">
	.content {
		height: 100vh;
		background: #ffffff;
		text-align: center;
		.pay_scs_info{
			padding: 200upx 0 280upx;
			.pay_scs_text{
				margin: 30upx 0 50upx;
				font-size: 36upx;
				color: #0e932e;
			}
			.icon-success{
				font-size: 160rpx;
				color: #0E932E;
			}
		}
		.btn7{
			width: 240rpx;
			height: 68rpx;
			line-height: 68rpx;
			border: none;
			border-radius: 6px;
			background: #ff4b4e;
			appearance: none;
			-webkit-appearance: none;
			display: inline-block;
			font-size: 32rpx;
			font-family: "microsoft yahei";
			text-align: center;
			color: #ffffff;
		}
		.btn8{
			width: 236rpx;
			height: 64rpx;
			line-height: 64rpx;
			border: 1px solid #ff4b4e;
			border-radius: 6px;
			background: none;
			appearance: none;
			-webkit-appearance: none;
			display: inline-block;
			font-size: 32rpx;
			font-family: "microsoft yahei";
			text-align: center;
			color: #ff4b4e;
		}
	}
</style>
